#include "time.h"
#include "stm32f10x.h"
#include "led.h"  // ????LED??????,????????????



// ???3?????
void TIM3_Int_Init(u16 arr,u16 psc)
{
    TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
    NVIC_InitTypeDef NVIC_InitStructure;

    // ??TIM3??
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); 

    // ???TIM3???
    TIM_TimeBaseStructure.TIM_Period = arr; // ???????????????????????????   
    TIM_TimeBaseStructure.TIM_Prescaler =psc; // ??????TIMx???????????
    TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; // ??????:TDTS = Tck_tim
    TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;  // TIM??????
    TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); // ??????????TIMx???????

    // ??TIM3??
    TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE ); 

    // ?????NVIC??
    NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;  // TIM3??
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;  // ?????0?
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;  // ????3?
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; // IRQ?????
    NVIC_Init(&NVIC_InitStructure);  // ??NVIC_InitStruct???????????NVIC???

    // ??TIM3
    TIM_Cmd(TIM3, ENABLE);          
}

// ???3??????
